package Day27;

public class Demo03 {
    public static void main(String[] args) {

        //注解
        Person p = new Person();
        p.setAge(18);
        p.setAge2(19);
    }
}
class Person{
    private int age;
     public int getAge(){
         return this.age;
     }

     /**
      * 此方法已经被废弃，请通过setAge2来操作
      * @param age
      * */
     @Deprecated
     public void setAge(int age){
         this.age = age;
     }

     public void setAge2(int age){
         if(age <0 || age > 120){
             System.out.println("数据不合理");
         }
         this.age = age;
     }
}